class HouseItem:
    def __init__(self, name, area):
        self.name = name
        self.area = area

    def __str__(self):
        return f"{self.name} 的占地面积是{self.area}平米"


class House:
    def __init__(self, name, area):
        self.name = name
        self.total_area = area
        self.free_area = area
        self.item_list = []

    def __str__(self):
        return f"户型：{self.name}，总面积：{self.total_area}，剩余面积：{self.free_area}，家具列表：{self.item_list}"

    def add_item(self, item):  # item为家具对象
        if self.free_area > item.area:
            self.item_list.append(item.name)
            self.free_area -= item.area
            print(f"家具（{item.name}），添加成功，剩余面积：{self.free_area}")
        else:
            print("家具添加失败，剩余空间不够，换个大房子吧")


bed = HouseItem('席梦思', 4)
chest = HouseItem('衣柜', 2)
table = HouseItem('餐桌', 1.5)
print(bed)
print(chest)
print(table)

house = House('三室一厅', 150)
house.add_item(bed)
house.add_item(chest)
print(house)
